package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsCollectMapper;
import com.qf.pojo.DtsCollect;
import com.qf.service.DtsCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * projectName:workspace_6
 * author:hyn
 * time:2021/12/1 11:42
 * description:会员收藏
 */
@Service
public class DtsCollectServiceImpl implements DtsCollectService {
    @Autowired
    private DtsCollectMapper collectMapper;
    @Override
    public IPage<DtsCollect> findAll(String valueId, String userId, Integer limit, Integer page, String sort, String order) {
        IPage<DtsCollect> ipage = new Page(page,limit);
        QueryWrapper<DtsCollect> wrapper = new QueryWrapper<>();
        if(!StringUtils.isEmpty(valueId)){
            wrapper.like("value_id",valueId);
        }
        if(!StringUtils.isEmpty(userId)){
            wrapper.like("user_id",userId);
        }
        if("asc".equals(order)){
            wrapper.orderByAsc(sort);
        }else{
            wrapper.orderByDesc(sort);
        }
        IPage<DtsCollect> p = collectMapper.selectPage(ipage, wrapper);
        return p;
    }
}
